由於我們太晚準備,被時間追著跑
老師建議我們先從UVA49道基本題目開始準備比較有感覺
因此今天我嘗試用課餘時間挑戰3題
俗話說建立信心就要從簡單題目開始著手,那就直接開始使用C++開始吧~
新手朋友可以下載瘋狂程設
,裡面有許多完整的UVA題目可練習,提交後也有系統的暗中測資,練習題目可以更心應手唷
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
int i,j,tmp;
int count=1,Mcount=0;
while(cin>>i>>j){
cout<<i<<" "<<j<<" ";
if(i>j){
tmp=i;
i=j;
j=tmp;
}
for(int t=i;t<=j;t++){
tmp=t;
//記數
do{
if(tmp%2==0)
tmp/=2;
else
tmp=3*tmp+1;
count++;
}while(tmp!=1);
Mcount=max(Mcount,count);
count=1;
}
cout<<Mcount<<endl;
Mcount=0;
}
}
#include <iostream>
#include<string>
using namespace std;
int main()
{
int days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
string week[]={"Friday","Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday"};
int N, M, D;
cin >> N;
while (N--)
{
cin >> M >> D;
int day = D;
for (int i = 0; i < M; i++) {day += days[i];}
cout<<week[day%7]<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main() {
int n, score=0, num=0;
string str;
cin >> n;
while (n > 0) {
cin >> str;
for (int i = 0; i < str.length(); i++) {
if (str[i] == 'O') {
num++;
score+=num;
}
else {
num = 0;
}
}
cout << score << endl;
n--; score = 0; num = 0;
}
}
以上是今天練習時的成果!雖然花費很多時在理解英文題目,題目都是數學邏輯題!一星題是只要想到可以直接寫出那種!
還有47題等著我哈哈哈